﻿@model UPMS.Core.Domain.Organization
@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="form-horizontal">
        <h4>Organization</h4>
        <hr />
        @Html.ValidationSummary(true)

        <div class="form-group">
            <div class="form-group">
                @Html.LabelFor(model => model.Name, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Name)
                    @Html.ValidationMessageFor(model => model.Name)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Description, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Description)
                    @Html.ValidationMessageFor(model => model.Description)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Created, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Created)
                    @Html.ValidationMessageFor(model => model.Created)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CreatedBy, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CreatedBy)
                    @Html.ValidationMessageFor(model => model.CreatedBy)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Modified, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Modified)
                    @Html.ValidationMessageFor(model => model.Modified)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.ModifiedBy, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.ModifiedBy)
                    @Html.ValidationMessageFor(model => model.ModifiedBy)
                </div>
            </div>
        </div>
    </div>
}
@section scripts{
    <script>
        $(function () {
            $.validator.unobtrusive.parse($('form[action="/Organization/create"]'));
            $(".btn.btn-primary").off("click.save");
            $(".btn.btn-primary").on("click.save", function () {

                if ($('form[action="/Organization/create"]').valid()) {

                    $.ajax({
                        type: "Post",
                        url: "/Organization/create",
                        data: $('form[action="/Organization/create"]').serialize(),
                        success: function (response) {
                            alert(response.status);
                        }
                    });
                }
            });
        });
    </script>
}